﻿@model PmpNetwork.Models.WikiArticlePart
@{
    Style.Require("jQueryUI_Orchard");
    Script.Require("jQuery").AtHead();
    Script.Require("Migrate").AtHead();

    Script.Require("PmpNetwork.WikiArticle.Edit");
    Script.Require("CKEditor");
}
<fieldset>
    <div class="editor-label"><label for="Name">@T("Name")</label></div>
    <div class="editor-field">
        @Html.TextBoxFor(x => x.Name, new { @class = "large text" })
        @Html.ValidationMessageFor(x => x.Name)
    </div>

    <div class="editor-label"><label for="NameOnUrl">@T("URL Friendly Name")</label></div>
    <div class="editor-field">
        @Html.TextBoxFor(x => x.NameOnUrl, new { @class = "large text" })
        @Html.ValidationMessageFor(x => x.NameOnUrl)
    </div>
    
    <div class="editor-label">@T("Content")</div>
    <div class="editor-field">
        @Html.TextAreaFor(x => x.Content, 25, 80,
	                     new Dictionary<string,object> {
		                    {"class", "html"},
                            {"style", "width:100%; height: 450px"}
	                     })
        @Html.ValidationMessageFor(x => x.Content)
    </div>  
</fieldset>
<script type="text/javascript">
    $(document).ready(function () {
        CKEDITOR.on('instanceReady', function () {
            var editorFrames = $(".cke_dialog_ui_input_file");

            if (editorFrames.length > 0) {
                $("<input type='hidden'/>")
                    .appendTo(editorFrames.contents().find("form"))
                    .attr("name", "__RequestVerificationToken")
                    .attr("value", "@Html.AntiForgeryTokenValueOrchard()");
            };
        });
        var editor = CKEDITOR.replace("Content", {
            toolbar:
            [
            ['Source'],
            ['Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript'],
            ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote', 'CreateDiv'],
            ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
            ['Link', 'Unlink', 'Anchor'],
            ['Image', 'Table', 'HorizontalRule', 'PageBreak', 'Iframe'],
            ['Maximize', 'ShowBlocks', '-', 'About'],
            ],
            skin: "v2",
            height: '600px',
            filebrowserUploadUrl: 'PmpNetwork/Upload/WikiImage',
            filebrowserImageUploadUrl: 'PmpNetwork/Upload/WikiImage'
        });

        

        var content = $('#Content');
        if (content.length > 0 && content[0].form) {
            var form = $(content[0].form);

            form.submit(function (e) {
                content.val(editor.getData());
                return true;
            });
        }
    });
</script>